package com.kaibes.core.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class NumButNullValidator implements ConstraintValidator<NumButNull, Number> {

    @Override
    public void initialize(NumButNull constraintAnnotation) {
    }

    @Override
    public boolean isValid(Number value, ConstraintValidatorContext context) {
        if (value != null) {
            return value.longValue() > 0;
        } else {
            return true;
        }
    }

}
